﻿#ifndef __REDIS_TASK_HEAD__
#define __REDIS_TASK_HEAD__

#include <string>
#include <vector>
#include <functional>

#include "multi_task/task.h"

struct S_RedisDataType;

class CRedisDbTask : public MultiTask::TaskBase
{
public:
	CRedisDbTask(const std::string &instName, const std::string &dbName, const std::string &collectionName, unsigned type, const std::string &queryString, const std::string &docString);
	~CRedisDbTask();

public:
	const char *GetName() override { return m_taskInstName.c_str(); }
	void Process(void *sharedObj) override;
	void OnCompleted() override;
//	void *CreateSharedObj(unsigned index) override;
	void Go() override;

private:
	std::string m_instName;
	std::string m_taskInstName;
	std::string m_dbName;
	std::string m_collectionName;
	unsigned    m_type;
	std::string m_queryString;
	std::string m_idString;
	bool m_bFirst;

	using DataSetType = std::vector<S_RedisDataType>;
	std::shared_ptr<DataSetType> m_datas;

public:
	
	using CBType = std::function<void()>;
	std::shared_ptr<MultiTask::TaskBase> SetCB(const CBType & cb);
	
private:
	CBType m_cb;
};

#endif 
